//
//  CollectNextTableViewCell.m
//  MarianasTrench
//
//  Created by wangjue on 16/3/19.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "CollectNextTableViewCell.h"

@interface CollectNextTableViewCell ()
@property (nonatomic, retain) UIImageView *leftImage;
@property (nonatomic, retain) UILabel *rightUpLabel;
@property (nonatomic, retain) UILabel *rightCenterLabel;
@property (nonatomic, retain) UILabel *rightDownLeftLabel;
@property (nonatomic, retain) UILabel *rightDownCenterLabel;
@property (nonatomic, retain) UILabel *rightDownRightLabel;
@property (nonatomic, retain) UIView *lineView;
@end

@implementation CollectNextTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    self.leftImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_leftImage];
    
    self.rightUpLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightUpLabel];
    
    self.rightCenterLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightCenterLabel];
    
    self.rightDownLeftLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightDownLeftLabel];
    
    self.rightDownCenterLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightDownCenterLabel];
    
    self.rightDownRightLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightDownRightLabel];
    
    self.lineView = [[UIView alloc] init];
    [self.contentView addSubview:_lineView];
}


-(void)layoutSubviews{
    [super layoutSubviews];
    
    _leftImage.frame = CGRectMake(10, 10, 80, 80);
    _leftImage.layer.cornerRadius = 40;
    _leftImage.layer.masksToBounds = YES;
    
    
    _rightUpLabel.frame = CGRectMake(100, 10, self.contentView.frame.size.width / 3 * 2, 15);
    _rightUpLabel.font = [UIFont systemFontOfSize:14];
    
    _rightCenterLabel.frame = CGRectMake(100, 40, self.contentView.frame.size.width / 2, 15);
    _rightCenterLabel.font = [UIFont systemFontOfSize:12];
    _rightCenterLabel.textColor = [UIColor grayColor];
    
    _rightDownLeftLabel.frame = CGRectMake(100, 60, self.contentView.frame.size.width / 4, 15);
    _rightDownLeftLabel.font = [UIFont systemFontOfSize:12];
    _rightDownLeftLabel.textColor = [UIColor grayColor];
    
    _rightDownCenterLabel.frame = CGRectMake(_rightDownLeftLabel.frame.origin.x + _rightDownLeftLabel.frame.size.width, 60, 70, 15);
    _rightDownCenterLabel.font = [UIFont systemFontOfSize:12];
    _rightDownCenterLabel.textColor = [UIColor grayColor];
    
    _rightDownRightLabel.frame = CGRectMake(_rightDownCenterLabel.frame.origin.x + _rightDownCenterLabel.frame.size.width, 60, 90, 15);
    _rightDownRightLabel.textColor = [UIColor grayColor];
    _rightDownRightLabel.font = [UIFont systemFontOfSize:12];
    
    _lineView.frame = CGRectMake(0, self.contentView.frame.origin.y, self.contentView.frame.size.width, 1);
    _lineView.backgroundColor = [UIColor grayColor];
}


-(void)setModel:(ListenModel *)model{
    _model = model;
    
    [_leftImage sd_setImageWithURL:[NSURL URLWithString:_model.coverMiddle] placeholderImage:[UIImage imageNamed:@"no_network@3x"]];
    
    _rightUpLabel.text = _model.title;
    
    _rightCenterLabel.text = [NSString stringWithFormat:@"by%@", _model.albumTitle];
    
    NSString *str = [NSString stringWithFormat:@"%.2f万",(float) _model.playtimes / 10000];
    _rightDownLeftLabel.text = [NSString stringWithFormat:@"播放:%@", str];
    
    _rightDownCenterLabel.text = [NSString stringWithFormat:@"喜欢:%@", _model.likes];
    
    _rightDownRightLabel.text = [NSString stringWithFormat:@"评论:%@", _model.comments];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
